package com.itheima.web1.controller;

import com.itheima.web1.pojo.Address;
import com.itheima.web1.pojo.Result;
import com.itheima.web1.pojo.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController//表示该类是一个控制器
public class HelloController {
    @RequestMapping("/hello")//表示该方法可以处理请求
    public Result hello(){
        System.out.println("hello");
        return Result.success("hello");
    }
    @RequestMapping("/getAddr")
    public Result getAddr(){
        User user=new User("张如玉",18,new Address("河北"));
        return Result.success(user);
    }
//    @RequestMapping("/simpleParam")
//    public String simpleParam(HttpServletRequest request){
//        String name = request.getParameter("name");
//        String ageStr = request.getParameter("age");
//        int age=Integer.parseInt(ageStr);
//        System.out.println("name:"+name+",age:"+age);
//        return "success";
//    }
    @RequestMapping("/simpleParam")
    public String simpleParam(String name,int age){
        System.out.println("name:"+name+",age:"+age);
        return "success";
    }
}
